﻿$(function () {

    $("#newService").click(function () {

        window.open("/Home/NewService/");

    })

    //开始任务
    $("#StartService").click(function () {
         
        AjaxPost($(this).data("taskid"), 1);
    })

    //刷新任务
    $("#RefreshService").click(function () {
         
        AjaxPost($(this).data("taskid"), 3);
    })

    //删除任务
    $("#DeleteService").click(function () {

        AjaxPost($(this).data("taskid"), 2);

    })


    function AjaxPost(taskid, type) {

        $.ajax({
            type: "post",
            data: {
                taskid: taskid,
                type: type
            },
            url: "/Home/SendMsg",
            beforeSend: function () {
                layer.load(0, { shade: [0.5, '#ccc'] })
            },
            success: function (data) {

                if (data.status) {
                    location.reload();
                }
                else {
                    layer.msg(data.msg, { icon: 2, time: 2000 });

                }
                layer.closeAll('loading');
            },
            complete: function () {
                layer.closeAll('loading');
            }
        });

    }

})